<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/1/19
  Time: 14:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>系统登录</title>
    <!--jquery核心包-->
    <script type="text/javascript" src="js/jquery.min.js" ></script>
    <!--easyui-->
    <script type="text/javascript" src="js/jquery.easyui.min.js" ></script>
    <script type="text/javascript" src="js/extJquery.js" ></script>
    <script type="text/javascript" src="js/extEasyUI.js" ></script>
    <script type="text/javascript" src="js/easyui-lang-zh_CN.js" ></script>

    <!--easyui样式引入-->
    <link rel="stylesheet" href="css/themes/default/easyui.css" />
    <link rel="stylesheet" href="css/themes/icon.css" />
    <link rel="stylesheet" href="css/style.css" />
</head>
<body style="background-color: #1f7cb6">
    <style>
        div{
            margin-top: 10px;
        }
    </style>
    <center style="margin-top: 300px">
        <form id="loginForm">
            <div style="width: 100%;height: 71px;text-align: center">
                <img src="img/loginlogo.png">
            </div>
            <div style="width: 100%;height: 30px">
                <input class="easyui-textbox" name="loginName"
                       data-options="iconCls:'icon-man'" value="hqj1234">
            </div>
            <div style="width: 100%;height: 30px">
                <input type="password" class="easyui-textbox" name="password" value="123456"
                       data-options="iconCls:'icon-lock'">
            </div>
            <div style="width: 100%;height: 30px">
                <input type="text" class="easyui-textbox" name="code"
                       data-options="width:80">
                <img src="code.jsp"
                     style="width: 60px;height: 23px;cursor: pointer;
                     vertical-align: bottom;border-radius: 5px"
                     id="code" onclick="changeCode()">
            </div>
            <div style="width: 100%;height: 30px;text-align: center">
                <a class="easyui-linkbutton" onclick="toLogin()" data-options="iconCls:'icon-save'">登录</a>
            </div>
        </form>
    </center>
    <script>
        $(function(){
            $(document).keypress(function (e) {
                if(e.keyCode == 13){
                    toLogin();
                }
            });

        });
        function toLogin() {
            var f = $("#loginForm");
            var data = f.serialize();
            $.ajax({
                type:'post',
                url:'${ctx}/uc/login',
                data:data,
                dataType:'json',
                success:function(result){
                    if(result.is){
                        window.location.href = '${ctx}/ic/index';
                    }else{
                        alert(result.msg);
                        changeCode();
                    }
                }
            });
        }
        function changeCode(){
            $('#code')[0].src = "${ctx}/code.jsp?"+new Date().getTime().toString();
        }

    </script>
</body>
</html>
